package selenium;


import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.selector.Html;

import java.util.List;

public class CasepSelenium {

    final static String DRIVER_PATH = "C:/Program Files/Mozilla Firefox/firefox.exe";
    final static String WEB_PATH = "https://www.capse.net/airline";

    public static void main(String[] args) throws InterruptedException {
        getHtml();
    }
    public static void getHtml() throws InterruptedException {
        System.setProperty("webdriver.firefox.bin", DRIVER_PATH);
        WebDriver driver = new FirefoxDriver();
        driver.get(WEB_PATH);
        WebElement webElement = driver.findElement(By.xpath("//*[@id=\"airportList\"]"));
        String content = webElement.getAttribute("outerHTML");
        Page page = new Page();
        page.setRawText(content);
        page.setHtml(new Html(content));
        List<String> list = page.getHtml().xpath("//*[@id=\"airportList\"]/table/tbody/tr/td/dl/dd/p/a").links().all();
        int i = 0;
        for (String str : list)
            System.out.println(++i + ":" + str);
        driver.close();
    }

}